﻿using System;
using System.Collections.Generic;
using System.Xml;
using System.Text;
using BfLib.Text;

namespace BfLib.Web.RSS
{
    public class RSSChannelImage
    {
        private string _url, _title, _link, _description;
        private int _width = 0, _height = 0;

        public RSSChannelImage(XmlNode node)
        {
            if (node == null)
                return;

            XmlNode n;

            n = node.SelectSingleNode("url");
            if (n != null)
            {
                this._url = n.Value;
            }

            n = node.SelectSingleNode("title");
            if (n != null)
            {
                this._title = n.Value;
            }

            n = node.SelectSingleNode("link");
            if (n != null)
            {
                this._link = n.Value;
            }

            n = node.SelectSingleNode("height");
            if (n != null)
            {
                this._width = n.Value.ToIntDef(0);
            }

            n = node.SelectSingleNode("width");
            if (n != null)
            {
                this._height = n.Value.ToIntDef(0);
            }

            n = node.SelectSingleNode("description");
            if (n != null)
            {
                this._description = n.Value;
            }

        }

        #region Public accessors

        public string Link
        {
            get { return _link; }
        }

        public string Title
        {
            get { return _title; }
        }

        public string Url
        {
            get { return _url; }
        }

        public string Description
        {
            get { return _description; }
        }

        public int MaxHeight
        {
            get { return _height; }
        }

        public int MaxWidth
        {
            get { return _width; }
        }

        #endregion
    }
}
